home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / Item Class / Item sources / CExtendDragTask.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  2.7 KB  |  146 lines  |  [TEXT/KAHL]

  1. /*
  2.  * File:        CExtendDragTask.c
  3.  * Created:        8/1/93
  4.  * Desc:        A mousetask that handles dragging and dropping
  5.  *                in CItemTable.
  6.  *
  7.  * Superclass:    CTableDragger.
  8.  * Uses:        CItemTable, CItem.
  9.  * Original Author:    W. Wesley Monroe
  10.  * Modifications:    Atul Barve
  11.  *
  12.  * Copyright © 1993 Animas Software Production. All rights reserved.
  13.  */
  14.  
  15. #include "CExtendDragTask.h"
  16. #include "CItemTable.h"
  17. #include "CItemList.h"
  18. #include "LongQD.h"
  19. #include "CItem.h"
  20.  
  21. extern CBureaucrat *gGopher;
  22.  
  23. void CExtendDragTask::IExtendDragTask(CTable *aTable,
  24.                                             CView *dragBoundsPane,
  25.                                             short theModifiers,
  26.                                             long selFlags)
  27. {
  28.     ITableDragger(aTable, theModifiers, selFlags);
  29.  
  30.  
  31.     fEnclosingPano = dragBoundsPane;
  32.     fGRDrawn = FALSE;
  33.     fFirst = TRUE;
  34.     fReleasedView = fOriginalView = aTable;
  35.     
  36.     fSelectedItems = 0L;
  37. }
  38.  
  39. void CExtendDragTask::Dispose(void)
  40. {
  41.     ForgetObject(fSelectedItems);
  42.  
  43.     inherited::Dispose();
  44. }
  45.  
  46. void CExtendDragTask::BeginTracking(LongPt *startPt)
  47. {
  48.     Cell        hitCell;
  49.     RgnHandle    aRgn;
  50.  
  51.     inherited::BeginTracking(startPt);
  52.     itsTable->FindHitCell(startPt, &hitCell);
  53.  
  54.         // Call Begin Tracking only if modifierkeys are down,
  55.         // or the hitCell is not Selected.....
  56.  
  57.     fSelRect.top = startPt->v;
  58.     fSelRect.bottom = startPt->v;
  59.     fSelRect.left = startPt->h;
  60.     fSelRect.right = startPt->v;
  61.     
  62. }
  63.  
  64. void CExtendDragTask::KeepTracking(LongPt *currPt, LongPt *prevPt,
  65.                                       LongPt *startPt)
  66. {
  67.     CView        *theDropInView;
  68.     CView        *enclView = fEnclosingPano;
  69.     CItemTable    *dropInTable;
  70.  
  71.     PenState    saveState;
  72.     Point    scp;
  73.     Cell    hitCell;
  74.     Rect    r, r2;
  75.     Point    cp;
  76.     
  77.     GetPenState(&saveState);
  78.  
  79.     if(fFirst && !EqualLongPt(currPt, prevPt)) {
  80.         r = fSelRect;
  81.         PenPat(gray);
  82.         PenMode(srcXor);
  83.         FrameRect(&r);
  84.         fFirst = FALSE;
  85.         fGRDrawn = TRUE;
  86.     } else if(!EqualLongPt(currPt, prevPt)) {
  87.         r = fSelRect;
  88.         PenPat(gray);
  89.         PenMode(srcXor);
  90.         FrameRect(&r);
  91.         if(currPt->h > startPt->h)
  92.             fSelRect.right = currPt->h;
  93.         else {
  94.             fSelRect.right = startPt->h;
  95.             fSelRect.left = currPt->h;
  96.         }
  97.             
  98.         if(currPt->v > startPt->v)
  99.             fSelRect.bottom = currPt->v;
  100.         else {
  101.             fSelRect.bottom = startPt->v;
  102.             fSelRect.top = currPt->v;
  103.         }
  104.         
  105.         
  106.         r = fSelRect;
  107.         FrameRect(&r);
  108.         fGRDrawn = TRUE;
  109.         fFirst = FALSE;
  110.         inherited::KeepTracking(currPt,prevPt,startPt);
  111.     }
  112.     SetPenState(&saveState);
  113. }
  114.  
  115. void CExtendDragTask::EndTracking(LongPt *currPt, LongPt *prevPt,
  116.                                      LongPt *startPt)
  117. {
  118.     CItemList    *selList;
  119.  
  120.     Cell dropCell = {0, 0};
  121.     Cell        hitCell;
  122.     PenState    saveState;
  123.     Rect        r;
  124.  
  125.  
  126.         // Erase the last gray region...
  127.     if(fGRDrawn) {
  128.  
  129.         GetPenState(&saveState);
  130.     
  131.         PenPat(gray);
  132.         PenMode(srcXor);
  133.         r = fSelRect;
  134.         FrameRect(&r);
  135.     
  136.         inherited::EndTracking(currPt,prevPt,startPt);
  137.         SetPenState(&saveState);
  138.         
  139.     }
  140.         // Region be gone...
  141.     ASSERT(fReleasedView);
  142.  
  143.     selList = fSelectedItems;
  144.  
  145. }
  146.